﻿@{
    ViewBag.Title = "模块管理》表单页面";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}
<script type="text/javascript">
    $(function () {
        LoadParent();
        InitControl();
    })
    //加载上级模块
    function LoadParent() {
        $("#ParentName").focus(function () {
            var objId = this.id;
            comboBoxTree(objId, "200px");
            var itemtree = {
                onnodeclick: function (item) {
                    $("#ParentId").val(item.id);
                    $('#ParentName').val(item.text);
                },
                url: "@Url.Content("~/CommonModule/Module/TreeJson")"
            };
            $("#comboBoxTree" + objId).treeview(itemtree);
            //移除Id上级元素
            $("#comboBoxTree" + objId + "_" + GetQuery('KeyValue').replace(/-/g, '_')).parent('li').remove();
        })
    }
    //得到一个对象实体
    function InitControl() {
        if (!!GetQuery('KeyValue')) {
            getAjax("/CommonModule/Module/SetFormControl", { KeyValue: GetQuery('KeyValue') }, function (data) {
                var data = eval("(" + data + ")");
                SetWebControls(data);
            });
        } else {
            //显示顺序
            AjaxJson("/CommonModule/Module/SortCode", {}, function (Data) {
                $("#SortCode").val(Data);
            })
            $("#ParentId").val(GetQuery('ModuleId'));
            $("#ParentName").val(GetQuery('ModuleName'));
        }
    }
    //保存事件
    function AcceptClick() {
        if (!CheckDataValid('#form1')) {
            return false;
        }
        Loading(true, "正在提交数据...");
        window.setTimeout(function () {
            var postData = GetWebControls("#form1");
            AjaxJson("/CommonModule/Module/SubmitForm?KeyValue=" + GetQuery('KeyValue'), postData, function (data) {
                tipDialog(data.Message, 3, data.Code);
                top.frames[tabiframeId()].windowload();
                closeDialog();
            });
        }, 200);
    }
</script>
<form id="form1" style="margin: 1px">
    <div id="message" style="display: none"></div>
    <table class="form">
        <tr>
            <th class="formTitle">模块编码：
            </th>
            <td class="formValue">
                <input id="Code" type="text" class="txt required" datacol="yes" err="模块编码" checkexpession="NotNull" />
            </td>
            <th class="formTitle">模块名称：
            </th>
            <td class="formValue">
                <input id="FullName" type="text" class="txt required" datacol="yes" err="模块名称" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">上级模块：
            </th>
            <td class="formValue">
                <input id="ParentId" type="hidden" />
                <input id="ParentName" type="text" class="txt icontree" />
            </td>
            <th class="formTitle">模块分类：
            </th>
            <td class="formValue">
                <select id="Category" class="txtselect">
                    <option value="目录">目录</option>
                    <option value="页面">页面</option>
                </select>
            </td>
        </tr>
        <tr>
            <th class="formTitle">Icon图标：
            </th>
            <td class="formValue">
                <input id="Icon" type="text" class="txt" />
            </td>
            <th class="formTitle">连接目标：</th>
            <td class="formValue">
                <select id="Target" class="txtselect">
                    <option value="iframe">iframe</option>
                    <option value="click">click</option>
                </select>
            </td>
        </tr>
        <tr>
            <th class="formTitle">级别层次：</th>
            <td class="formValue">
                <input id="Level" type="text" onkeyup="IsNumber(this.id)" class="txt required" datacol="yes" err="级别层次" checkexpession="Num" />
            </td>
            <th class="formTitle">显示顺序：</th>
            <td class="formValue">
                <input id="SortCode" type="text" onkeyup="IsNumber(this.id)" class="txt" datacol="yes" err="显示顺序" checkexpession="Num" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">选项：</th>
            <td class="formValue" colspan="3">
                <span class="item">
                    <input type="checkbox" name="checkbox" id="Authority" />
                    <label for="Authority">访问权限</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" id="DataScope" />
                    <label for="DataScope">数据范围</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" id="AllowView" />
                    <label for="AllowView">动态视图</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" id="AllowButton" />
                    <label for="AllowButton">动态按钮</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" id="AllowForm" />
                    <label for="AllowForm">动态表单</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" id="Isexpand" />
                    <label for="Isexpand">展开</label>
                </span>
                <span class="item">
                    <input type="checkbox" name="checkbox" checked="checked" id="Enabled" />
                    <label for="Enabled">有效</label>
                </span>
            </td>
        </tr>
        <tr>
            <th class="formTitle">访问地址：
            </th>
            <td class="formValue" colspan="3">
                <input id="Location" type="text" class="txt" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">说明：
            </th>
            <td class="formValue" colspan="3">
                <textarea id="Remark" name="Description" maxlength="200" class="txtArea" rows="5"></textarea>
            </td>
        </tr>
    </table>
</form>
